//
//  VCOfSecond.m
//  07--Delegate Block
//
//  Created by 冀永金 on 16/7/22.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "VCOfSecond.h"

@interface VCOfSecond ()
@property (nonatomic, strong) UIButton *backButton;
@end

@implementation VCOfSecond

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.textField = [[UITextField alloc]initWithFrame:CGRectMake(50, 50, self.view.frame.size.width - 100, 40)];
    [self.view addSubview:_textField];
    
   self.backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _backButton.frame = CGRectMake(50, 100, 100, 80);
    [self.view addSubview:_backButton];
    _backButton.backgroundColor = [UIColor redColor];
    [_backButton setTitle:@"返回" forState:UIControlStateNormal];
    [_backButton addTarget:self action:@selector(handleBack:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    // Do any additional setup after loading the view.
}
- (void)handleBack:(UIButton *)button {
    [self.navigationController popViewControllerAnimated:YES];
    if (self.delegate && [self.delegate respondsToSelector:@selector(setText:)]) {
        [self.delegate setText:self.textField.text];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
